# -*- coding:utf-8 -*-

__author__ = 'LookCheng'
from flask_script import Shell,Manager
from flask_migrate import Migrate,MigrateCommand

from app import db,create_app
from app.models import Joke, Tag
app = create_app('default')

manager = Manager(app)
def make_shell_context():
    return dict(app=app, db=db, Joke=Joke, Tag=Tag)
manager.add_command("shell",Shell(make_context=make_shell_context))

migrate = Migrate(app,db)
manager.add_command('db',MigrateCommand)

if __name__ == '__main__':
    manager.run()


# ##
# """
# 1.初始化数据库
# python hellodb.py db init
#
# 2.自动创建迁移脚本
# python hellodb.py db migrate -m "initial migration"
#
# 3.更新数据库
# python hellodb.py db upgrade
    # 4. 删除改动
    #  python hellodb.py db downgrade
# """
# ####